/*
 * @Author       : NaN 353362604@qq.com
 * @Date         : 2023-01-12 09:35:49
 * @LastEditTime : 2023-04-04 10:57:51
 * @LastEditors  : NaN 353362604@qq.com
 * @FilePath     : \AdminStration\src\Common\Modal\TwoModalList\ProjectBuildList.jsx
 * @Description  :
 */
import { API_LIST } from '../../Api/Api'
import { TwoAddBtn, ThrDeleteBtn, SeeEnclosure } from '../options'
import { commonTableList } from '../config'
export const ProjectBuildList = async ({ upDataEvent, data, Permission }) => {
    let dataList = {
        type: '建设程序',
        hideInSearch: true,
        pageSize: 10,
        params: {},
        classification: 'PPPBox',
        dataType: 1,
        get: API_LIST([data.organizationUuid || data.uuid])['getOrganizationBuildListAttachmentAll'],
        options: [
            Permission.findIndex(v => v.uuid === '0983943a-daf0-4c92-9fef-18ee06ba638c') !== -1 && (
                <TwoAddBtn
                    upDataEvent={upDataEvent}
                    title="添加文件附件"
                    ThrKey="ThrModal"
                    value="ProjectBuildList"
                    data={data}
                />
            ),
        ],
        columns: [
            { ...commonTableList.tableName, title: '名称' },
            { ...commonTableList.sortId },
            {
                dataIndex: 'buildListUuid',
                title: '清单名称',
                valueType: 'input',
                render: (_, e) => <div>{e.organizationBuildList.buildList.fullName}</div>,
            },
            {
                title: '创建时间',
                dataIndex: 'createTime',
                valueType: 'input',
                hideInTable: true,
                hideInAdded: true,
                hideInModify: true,
            },
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 500,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    const { attachment } = record
                    return [
                        attachment.fileUrl && (
                            <SeeEnclosure
                                key="see"
                                title="查看附件"
                                data={{
                                    className: 'Admin',
                                    url: attachment.fileUrl,
                                }}
                            />
                        ),
                        Permission.findIndex(v => v.uuid === '49767e17-8d49-4bd6-9ffc-129969267cd7') !== -1 && (
                            <ThrDeleteBtn
                                key="delete"
                                record={record.uuid}
                                upDataEvent={upDataEvent}
                                data={{ key: 'delete', url: 'delOrganizationBuildListAttachment', title: '删除附件' }}
                            />
                        ),
                    ]
                },
            },
        ],
    }

    return dataList
}
